package com.tadpole.music.holder.screen;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.tadpole.music.R;
import com.tadpole.music.adapter.base.BaseAdapter;
import com.tadpole.music.bean.study.QuestionBean;
import com.tadpole.music.holder.base.BaseViewHolder;
import com.tadpole.music.utils.NoDoubleClickListener;

import java.util.List;

/**
 * Created By 孙岩
 * on 2020/9/28
 */
public class ScreenQuestionViewHolder extends BaseViewHolder {
    private View itemView;
    private BaseAdapter.OnItemClickListener onItemClickListener;
    private TextView tvName;
    private List<QuestionBean> questionList;
    private Activity activity;
    public ScreenQuestionViewHolder(Activity activity,View itemView, BaseAdapter.OnItemClickListener onItemClickListener,List<QuestionBean> questionList) {
        super(itemView);
        this.itemView = itemView;
        this.onItemClickListener = onItemClickListener;
        this.questionList = questionList;
        this.activity = activity;
    }

    @Override
    public void init(final int position) {
        tvName = itemView.findViewById(R.id.tvName);
        tvName.setText(questionList.get(position).getName());

        if(questionList.get(position).isSelect()){
            tvName.setBackground(activity.getResources().getDrawable(R.drawable.shape_main_line_small));
            tvName.setTextColor(activity.getResources().getColor(R.color.colorMain));
        }else{
            tvName.setBackground(activity.getResources().getDrawable(R.drawable.shape_gray_line_small));
            tvName.setTextColor(activity.getResources().getColor(R.color.color_9a));
        }

        itemView.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                onItemClickListener.onItemClick(itemView,position);
            }
        });
    }
}
